package com.schoolvisitors.converter;

import com.schoolvisitors.enums.RoomTypeEnum;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter(autoApply = true)
public class RoomTypeEnumConverter implements AttributeConverter<RoomTypeEnum, Integer> {

    @Override
    public Integer convertToDatabaseColumn(RoomTypeEnum roomType) {
        return roomType.getCode();
    }

    @Override
    public RoomTypeEnum convertToEntityAttribute(Integer roomType) {
        return RoomTypeEnum.fromCode(roomType);
    }
}
